home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 February / EnigmA AMIGA RUN 15 (1997)(G.R. Edizioni)(IT)[!][issue 1997-02][PLANET CD V].iso / enigma / earcd / emula / arosdv19.lha / AROS / exec / copymemquick.c < prev    next >
C/C++ Source or Header  |  1996-10-24  |  2KB  |  103 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: copymemquick.c,v 1.5 1996/10/24 15:50:46 aros Exp $
  4.     $Log: copymemquick.c,v $
  5.     Revision 1.5  1996/10/24 15:50:46  aros
  6.     Use the official AROS macros over the __AROS versions.
  7.  
  8.     Revision 1.4  1996/08/13 13:55:59  digulla
  9.     Replaced AROS_LA by AROS_LHA
  10.     Replaced some AROS_LH*I by AROS_LH*
  11.     Sorted and added includes
  12.  
  13.     Revision 1.3  1996/08/01 17:41:07  digulla
  14.     Added standard header for all files
  15.  
  16.     Desc:
  17.     Lang:
  18. */
  19. #include <aros/libcall.h>
  20.  
  21. /*****************************************************************************
  22.  
  23.     NAME */
  24.     #include <exec/types.h>
  25.  
  26.     AROS_LH3I(void, CopyMemQuick,
  27.  
  28. /*  SYNOPSIS */
  29.     AROS_LHA(APTR,  source, A0),
  30.     AROS_LHA(APTR,  dest,   A1),
  31.     AROS_LHA(ULONG, size,   D0),
  32.  
  33. /*  LOCATION */
  34.     struct ExecBase *, SysBase, 105, Exec)
  35.  
  36. /*  FUNCTION
  37.     Copy some longwords from one destination in memory to another using
  38.     a fast copying method.
  39.  
  40.     INPUTS
  41.     source - Pointer to source area (must be ULONG aligned)
  42.     dest   - Pointer to destination (must be ULONG aligned)
  43.     size   - number of bytes to copy (must be a multiple of sizeof(ULONG))
  44.  
  45.     RESULT
  46.  
  47.     NOTES
  48.     The source and destination area are not allowed to overlap.
  49.  
  50.     EXAMPLE
  51.  
  52.     BUGS
  53.  
  54.     SEE ALSO
  55.     CopyMem()
  56.  
  57.     INTERNALS
  58.  
  59.     HISTORY
  60.     22-10-95    Created by M. Fleischer
  61.  
  62. ******************************************************************************/
  63. {
  64.     AROS_LIBFUNC_INIT
  65.  
  66.     ULONG low,high;
  67.  
  68.     /* Calculate number of ULONGs to copy */
  69.     size/=sizeof(ULONG);
  70.  
  71.     /*
  72.     To minimize the loop overhead I copy more than one (eight) ULONG per
  73.     iteration. Therefore I need to split size into size/8 and the rest.
  74.     */
  75.     low =size&7;
  76.     high=size/8;
  77.  
  78.     /* Then copy for both parts */
  79.     if(low)
  80.     do
  81.         *((ULONG *)dest)++=*((ULONG *)source)++;
  82.     while(--low);
  83.  
  84.     /*
  85.     Partly unrolled copying loop. The predecrement helps the compiler to
  86.     find the best possible loop. The if is necessary to do this.
  87.     */
  88.     if(high)
  89.     do
  90.     {
  91.         *((ULONG *)dest)++=*((ULONG *)source)++;
  92.         *((ULONG *)dest)++=*((ULONG *)source)++;
  93.         *((ULONG *)dest)++=*((ULONG *)source)++;
  94.         *((ULONG *)dest)++=*((ULONG *)source)++;
  95.         *((ULONG *)dest)++=*((ULONG *)source)++;
  96.         *((ULONG *)dest)++=*((ULONG *)source)++;
  97.         *((ULONG *)dest)++=*((ULONG *)source)++;
  98.         *((ULONG *)dest)++=*((ULONG *)source)++;
  99.     }while(--high);
  100.     AROS_LIBFUNC_EXIT
  101. } /* CopyMemQuick */
  102.  
  103.